/*
 * TLSLink.h
 *
 *  Created on: 30/10/2011
 *      Author: godinho
 */

#ifndef TLS_LINK_H_
#define TLS_LINK_H_

class SimulationNode;

/**
 * Represents a link inside a simulation node.
 *
 * A link represents the source and destine allowed inside the node. Objects
 * of this class are used with Phase to describe the allowed movements in
 * a junction on a given time.
 *
 * It is a immutable object
 */
class TLSLink {
public:
	/**
	 * Constructs a link object.
	 *
	 * @param from Node which is source of cars on a link
	 * @param to Node which is destine of car on a link
	 */
	TLSLink(SimulationNode* from, SimulationNode* to, int meanFlush);

	/**
	 * Destructor.
	 */
	virtual ~TLSLink();

	/**
	 * Returns the source of link
	 *
	 * @return SimulationNode
	 */
    SimulationNode *getFrom() const;

    /**
     * Returns the destine of car.
     */
    SimulationNode *getTo() const;

    /**
     * Move cars from source to destine.
     *
     * @param ration Fraction of cars that must be moved, 1 to move all cars.
     * @param number of cars moved.
     */
    int move(float ratio);

    /**
     * Get current mean flush for this link.
     *
     * The flush is the amount of cars per second that use this link.
     *
     * @return quantity of cars per second.
     */
    int getFlush();

    void setIntersectionNode(SimulationNode* intersectionNode);

private:
    SimulationNode* mIntersectionNode;
	SimulationNode* mFrom;
	SimulationNode* mTo;
	int mFlush;
};

#endif /* TLS_LINK_H_ */
